package com.gitee.baqkft.code.ui.component;

import com.gitee.baqkft.code.ui.layout.GBC;

import javax.swing.*;
import java.awt.*;

/**
 * Table配置面板
 * @Author: chenmingcai
 * @Date 2020/5/30 2:58 下午
 **/

public class TableConfigPanel extends JPanel
{
    /**
     * 数据包名称
     */
    private final JTextField tableName;

    /**
     * 对象名称
     */
    private final JTextField objectName;

    public TableConfigPanel()
    {
        this(null);
    }

    public TableConfigPanel(String table)
    {
        setLayout(new GridBagLayout());
        JLabel label = new JLabel("Table Name:");
        GBC gbc = new GBC(0, 0, 1, 1);
        gbc.setWeight(0, 1).setFill(GBC.VERTICAL);
        add(label, gbc);

        tableName = new JTextField();
        if(table != null)
            tableName.setText(table);

        gbc = new GBC(1, 0, 1, 1);
        gbc.setWeight(1, 1).setFill(GBC.BOTH);
        add(tableName, gbc);

        label = new JLabel("Object Name:");
        gbc = new GBC(2, 0, 1, 1);
        gbc.setWeight(0, 1).setFill(GBC.VERTICAL);
        add(label, gbc);

        objectName = new JTextField();
        gbc = new GBC(3, 0, 1, 1);
        gbc.setWeight(1, 1).setFill(GBC.BOTH);
        add(objectName, gbc);
    }

    /**
     * 表名称
     * @return
     */
    public String getTableName()
    {
        return tableName.getText();
    }

    /**
     * 对象名称
     * @return
     */
    public String getObjectName()
    {
        return objectName.getText().trim();
    }
}
